In certain circumstances, software functions or applications may desire to behave differently based on who or what is calling the function. For example, a user may desire to create a monitoring function that is called by certain applications to collect statistics or other information about each application. Because each application is different and has different usage scenarios and characteristics, the user may desire that the monitoring function collect different statistics and behave differently based on which application is calling the monitoring function. However, a static monitoring function may not be aware of which application is calling it, making such application tailored behavior difficult.
One solution to this problem is the use of dynamic functions. For dynamic functions, the code is generated when the functions are called, and therefore the code can be tailored at runtime to the particular calling application or function.
However, there are drawbacks associated with dynamic code. First, generating dynamic code at runtime requires a code generation engine, which can be large and may require increased memory and processing resources when compared to static code. Second, dynamically generated code may not be as stable as static code, and therefore may lead to a diminished experience for the end user.